import React, { useImperativeHandle, useRef } from 'react'

 function FunTest(props, ref) {
    // console.log('ref',ref);// 父组件传递过来的ref对象
    const myRef = useRef()
    useImperativeHandle(ref, () => ({
        changeColor() {
            myRef.current.style.color = 'green'
        }
    }))
  return (
    <div>
      <h4>Function</h4>
      <h4 ref={myRef}>ref传递的值</h4>
    </div>
  )
}
export default React.forwardRef(FunTest)
